class ErrorMsgs {
  static const NOT_NULL = '不能为空';
  static const FORMAT_ILLEGAL = '格式非法';
  static String MAX_LENGTH(int length) => '长度不能大于${length}位';
  static String MIN_LENGTH(int length) => '长度不能小于${length}位';
  static String NUM_RANGE(int min, int max) => '必须为${min}—${max}之间个字符';
  static String STRING_RANGE(int min, int max) => '必须为${min}—${max}之间个字符';

  /// 校验数据是否为空
  static String? validNull(dynamic value) {
    if (value == null) {
      return NOT_NULL;
    }

    if (value is String) {
      return (value == '') ? NOT_NULL : null;
    } else if (value is List) {
      return (List.of(value).length > 0) ? null : NOT_NULL;
    }

    return null;
  }
}
